<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<html>
	<head>
		<title>IdeaPad - View Group</title>
		<link rel="stylesheet" type="text/css" href="styles/main.css">
		<link rel="stylesheet" type="text/css" href="styles/buttons.css">
		<link rel="stylesheet" type="text/css" href="styles/currentbutton.css">
	</head>
	<body>
		<div class="header">
			<html:link action="/default">
				<img src="/IdeaPad/images/ideapad_logo.png" alt="logo" border="0" />
			</html:link>
			<%
				if (session.getAttribute("username") == null || session.getAttribute("username") == "") {
			%>
			<html:link page="/form/login.jsp" styleClass="menubuttons">Login</html:link>
			<html:link page="/form/registerUser.jsp" styleClass="menubuttons">Register</html:link>
			<%
				} else {
			%>
			Hello
			<%=session.getAttribute("username").toString()%>
			<html:link action="viewGroups" styleClass="currentbutton">Groups</html:link>
			<html:link action="manageGroups" styleClass="menubuttons">Manage Groups</html:link>
			<html:link page="/form/editUserSettings.jsp" styleClass="menubuttons">Settings</html:link>
			<html:link action="logout" styleClass="menubuttons">Logout</html:link>
			<%
				}
			%>
		</div>

		<h1>
			Group:
			<bean:write name="groupName" scope="request" />
		</h1>

		<logic:messagesPresent>
			<font color="red"> <logic:iterate name="Errors" id="Error"
					scope="request">
					<bean:write name="Error" />
					<br />
				</logic:iterate> </font>
		</logic:messagesPresent>

		<logic:notEmpty name="groups" scope="request">
			<h1>
				Child Groups
			</h1>
			<table border="1">
				<tr>
					<td>
						Group ID
					</td>
					<td>
						Group Name
					</td>
					<td>
						Parent Group
					</td>
				</tr>

				<logic:iterate name="groups" id="group" scope="request">
					<tr>
						<td>
							<bean:write name="group" property="groupId" />
						</td>
						<td>
							<html:link action="viewGroup">
								<bean:write name="group" property="groupName" />
								<bean:define id="groupID" name="group" property="groupId" />
								<html:param name="groupID" value="<%= groupID.toString()%>" />
							</html:link>
						</td>
						<td>
							<logic:empty name="group" property="parentGroup">NONE</logic:empty>
							<logic:notEmpty name="group" property="parentGroup">
								<bean:write name="group" property="parentGroup.groupName" />
							</logic:notEmpty>
						</td>
					</tr>
				</logic:iterate>
			</table>
		</logic:notEmpty>

		<logic:notEmpty name="groupID" scope="request">
			<html:link action="viewMembers">
			View Group Members
			<html:param name="groupID"
					value="<%= request.getAttribute("groupID").toString() %>" />
			</html:link>
		</logic:notEmpty>

		<br />

		<logic:notEmpty name="groupID" scope="request">
			<html:link action="ideaList">
			View Ideas
			<html:param name="groupID"
					value="<%= request.getAttribute("groupID").toString() %>" />
			</html:link>
		</logic:notEmpty>
	</body>
</html>

